package com.yc.controller.xcx;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yc.controller.weixin.GenericController;
import com.yc.entity.Page;
import com.yc.entity.xcx.PickerObject;
import com.yc.service.system.hospital.ICategoryManager;
import com.yc.util.PageData;
import com.yc.util.ReturnModel;


@Controller
@RequestMapping("/app/category")
public class ECategoryController extends GenericController {

	@Resource
	private ICategoryManager categoryManager;
	
	
	//科室下拉表
	@RequestMapping(value="/getListByHID")
	public void getCategoryList(HttpServletResponse response,String hospitalID)throws Exception{
		
		PageData pd = new PageData();
		pd.put("HOSPITAL_ID", hospitalID);
		
		List<PageData> list = categoryManager.getCategoryListByHID(pd);
		
		ReturnModel returnModel = new ReturnModel();
		PickerObject obj =new PickerObject();
		
		List ids = new ArrayList<String>();
		List values = new ArrayList<String>();
		
		ids.add(0);
		values.add("请选择科室");
		
		
		for(PageData item :list){
			ids.add(item.getString("CATEGORY_ID").toString());
			values.add(item.getString("CATEGORYNAME").toString());
		}
		
		obj.setIds(ids);
		obj.setValues(values);
		
		returnModel.setResult(true);
		returnModel.setReason(null);
		returnModel.setDatum(obj);
		
		this.renderString(response, returnModel);
		
	}
	
	
}
